<?php
	class Main_Model extends CI_Model {

		function __construct(){
			parent::__construct();
		}
		
		function content($id){	
			$this->db->where('id_content',$id);
			$query = $this->db->get('content');
			return $query->row();
		}

		function setting($id){	
			$this->db->where('id_setting',$id);
			$query = $this->db->get('setting');
			return $query->row();
		}

		function daftar($data){	
			$query = $this->db->insert('member',$data);
			return $query;
		}

		function provinsi(){
			$this->db->order_by('provinsi');
			$query = $this->db->get('provinsi');
			return $query->result();
		}

		function login($username,$password){
			$sql="SELECT * FROM member WHERE email='".$username."' AND password='".$password."' LIMIT 1";
			//echo $sql;
			$query=$this->db->query($sql);
			if ($query->num_rows()>0){
				return $query->row_array();
			}else{
				return false;
			}	
		}
	
		function cekStatus($id){
			$sql="SELECT * FROM member WHERE id_member=$id";
			//echo $sql;
			$query=$this->db->query($sql);
			
			if ($query->num_rows()>0){
				$tmp_data=$query->row_array();
				if($tmp_data['status_aktif']==1){
					return true;
				}else{
					return false;
				}
			}else{
				return false;
			}	
		}	

		function statusMember($id){
			$this->db->select('status_member');
			$this->db->where('id_member',$id);
			$query = $this->db->get('member');
			return $query->row();
		}

		function update_premium($id_member,$data){
			$this->db->where('id_member', $id_member);
			$update = $this->db->update('member', $data);
			return $update;
		}
	}
?>